#! /bash/bin
db_name=fujunhua
hive -e "
use $db_name;
add jar hdfs:///user/fujunhua/myjar/app_tags-jar-with-dependencies.jar;
create temporary function mysplit as 'com.antg.udf.MySplit';
create temporary function percentage as 'com.antg.udf.Convert';
insert overwrite table app_hot_rank
select tag,num,rank,percentage(percentage) percentage,all_num from
(select tag,num,
rank() over(order by num desc) rank,
num/sum(num) over() percentage
from (select tag,count(1) num from app_abstract_info lateral view explode(mysplit(tags)) tag_table as tag group by tag order by num desc) a
) b
left join
(select count(1) all_num from app_abstract_info) c;
"
